Team Synergy

1/25
` }, { id: "ch1_4", tag: "บทที่ 1 : ธรรมชาติของทีม", title: "หัวใจของการสร้างทีม", render: () => `
หัวใจของการสร้างทีม
Actionable Takeaway

เริ่มสร้างทีมอย่างไรดี?

สูตรลัดลงมือทำ (Take Action ทันที) มีเพียง 3 เสาหลักครับ:

01

Set the North Star

เป้าหมายทีมชัดเจนเหมือนดาวเหนือ

02

Know the Roles

กำหนดบทบาทให้ชัด ใครทำอะไร

03

Establish Ground Rules

ตกลงกติกาการอยู่ร่วมกัน การสื่อสาร

` }, { id: "ch2_1", tag: "บทที่ 2 : ศิลปะการสื่อสารไร้รอยต่อ", title: "หลุมพรางของการสื่อสาร", render: () => `
หลุมพรางของการสื่อสาร

หลุมพรางของการสื่อสาร

ทีมที่เก่งที่สุด ก็ล้มเหลวได้ ถ้าคุยกันไม่รู้เรื่อง! นี่คือ 3 หลุมพรางคลาสสิกที่ทำให้งานสะดุด

ฟังเพื่อตอบ ไม่ได้ฟังเพื่อเข้าใจ

มัวแต่คิดว่าประโยคต่อไปจะเถียงอะไร จนลืมฟังความหมายที่แท้จริง

ทึกทักไปเอง (Assumption)

คิดเอาเองว่า "เขาคงรู้แล้ว" โดยไม่ได้อธิบายให้ชัดเจน

ความเงียบที่อันตราย

เห็นปัญหาแต่ไม่พูด เพราะกลัวบรรยากาศเสีย (Artificial Harmony)

` }, { id: "ch2_2", tag: "บทที่ 2 : ศิลปะการสื่อสารไร้รอยต่อ", title: "Active Listening & Feedback", render: () => `
Active Listening & Feedback

ศิลปะการฟัง & Feedback

เปลี่ยนหลุมพราง เป็นพลังแห่งความเข้าใจ ด้วย 2 อาวุธลับ

Active Listening (ฟังเชิงรุก)

  • ฟังด้วยหู: จับใจความเนื้อหา
  • ฟังด้วยตา: สังเกตภาษากาย สีหน้า
  • ฟังด้วยใจ: เข้าใจอารมณ์และความรู้สึกที่ซ่อนอยู่ ทวนคำเพื่อคอนเฟิร์ม

Constructive Feedback

  • Feedback คือ ของขวัญ ไม่ใช่การจับผิด
  • ใช้หลัก SBI: Situation (สถานการณ์) + Behavior (พฤติกรรม) + Impact (ผลกระทบ)
  • เน้นไปที่เหตุการณ์ ไม่โจมตีตัวบุคคล
` }, { id: "ch2_3", tag: "บทที่ 2 : ศิลปะการสื่อสารไร้รอยต่อ", title: "Interactive: เมื่อเกิดความขัดแย้ง?", render: () => `
Interactive: เมื่อเกิดความขัดแย้ง?
Interactive

คุณจะสื่อสารอย่างไร?

"ในที่ประชุม เพื่อนร่วมทีมเสนอไอเดียโปรเจกต์ใหม่ ซึ่งคุณมองเห็นช่องโหว่ชัดเจนว่ามันจะทำให้งบบานปลาย..."
` }, { id: "ch2_4", tag: "บทที่ 2 : ศิลปะการสื่อสารไร้รอยต่อ", title: "สื่อสารดี ทีมเดินไว", render: () => `
สื่อสารดี ทีมเดินไว
Actionable Takeaway

สื่อสารดี ทีมเดินไว

สูตรลัดลงมือทำ: เปลี่ยนการสื่อสารให้เป็นสะพาน ไม่ใช่กำแพง

Radical Candor (พูดตรงด้วยความใส่ใจ)

กล้าท้าทายกันโดยตรง แต่ตั้งอยู่บนพื้นฐานของความใส่ใจในตัวบุคคล

สร้าง Safe Space

สร้างพื้นที่ปลอดภัยที่ทุกคนพูดไอเดียโง่ๆ ได้โดยไม่ถูกหัวเราะเยาะ

"เราจะกล้าสื่อสารตรงๆ ได้ ก็ต่อเมื่อเรารู้สึกปลอดภัย... บทต่อไปเราจะมาสร้าง 'รากฐานแห่งความไว้วางใจ (Trust)' กันครับ"
` }, { id: "ch3_1", tag: "บทที่ 3 : รากฐานแห่งความไว้วางใจ", title: "Trust คือกาวใจที่ยึดโยงทีม", render: () => `
Trust คือกาวใจที่ยึดโยงทีม

Trust คือกาวใจของทีม

Patrick Lencioni ผู้เชี่ยวชาญด้านทีมเวิร์ค กล่าวว่า "ความไร้ซึ่งความไว้วางใจ" คือความผิดปกติระดับฐานรากที่สุดของทีม

เมื่อทีมขาด Trust (Low Trust):

  • สมาชิกจะปกปิดความผิดพลาดของตัวเอง
  • ลังเลที่จะขอความช่วยเหลือ
  • มัวแต่ระแวงและจับผิดกันเอง ทำให้งานช้า

เมื่อทีมมี Trust สูง (High Trust):

  • กล้ายอมรับความอ่อนแอ (Vulnerability)
  • ดึงศักยภาพสูงสุดออกมาใช้ได้เต็มที่
  • เคลื่อนที่เร็ว เพราะไม่ต้องเสียเวลาตรวจสอบกันเองซ้ำซ้อน
` }, { id: "ch3_2", tag: "บทที่ 3 : รากฐานแห่งความไว้วางใจ", title: "สมการความไว้วางใจ", render: () => `
สมการความไว้วางใจ

สมการความไว้วางใจ

The Trust Equation (โดย Charles H. Green)

( ความน่าเชื่อถือ + ความพึ่งพาได้ + ความใกล้ชิด )

การยึดตัวเองเป็นที่ตั้ง
1. ความน่าเชื่อถือ (Credibility) รู้ลึก รู้จริง ทำงานมีคุณภาพ
2. ความพึ่งพาได้ (Reliability) รับปากแล้วทำได้ ส่งงานตรงเวลา
3. ความใกล้ชิด (Intimacy) มีความปลอดภัยทางอารมณ์ คุยได้ทุกเรื่อง
ตัวหาร: การยึดตัวเอง (Self-Orientation) ถ้าทำเพื่อผลประโยชน์ส่วนตัว Trust จะลดฮวบทันที
` }, { id: "ch3_3", tag: "บทที่ 3 : รากฐานแห่งความไว้วางใจ", title: "Interactive: เช็คระดับ Trust", render: () => `
Interactive: เช็คระดับ Trust
Interactive

ทีมคุณมีพฤติกรรมแบบไหน?

เวลาเกิดความผิดพลาดในโปรเจกต์สำคัญ สมาชิกในทีมมักจะ...

` }, { id: "ch3_4", tag: "บทที่ 3 : รากฐานแห่งความไว้วางใจ", title: "สร้าง Trust ให้ทีมเวิร์ค", render: () => `
สร้าง Trust ให้ทีมเวิร์ค
Actionable Takeaway

ลงมือสร้าง Trust ตั้งแต่วันนี้

1

รักษาสัญญา (Keep Promises)

เรื่องเล็กๆ อย่างการเข้าประชุมตรงเวลา ส่งอีเมลตามกำหนด คือการสะสมคะแนน Trust ที่ดีที่สุด

2

กล้ายอมรับผิด (Admit Mistakes)

คำว่า "ผมพลาดเอง" หรือ "ขอโทษที" จากหัวหน้าหรือเพื่อนร่วมทีม คือตัวละลายพฤติกรรมชั้นยอด

3

เอาใจเขามาใส่ใจเรา (Empathy)

ลดความยึดตัวเองเป็นที่ตั้ง (Self-Orientation) แล้วโฟกัสที่เป้าหมายร่วมกันของทีม

` }, { id: "ch4_1", tag: "บทที่ 4 : ทีมเวิร์คที่ยืดหยุ่น", title: "โลกเปลี่ยน ทีมต้องปรับ", render: () => `
โลกเปลี่ยน ทีมต้องปรับ

โลกเปลี่ยนเร็ว ทีมต้องปรับไว

ในยุค Disruption ความสมบูรณ์แบบ (Perfection) อาจทำให้เราเดินช้าเกินไป ความยืดหยุ่น (Adaptability) ต่างหากคือกลยุทธ์แห่งผู้ชนะ

ทีมแบบดั้งเดิม (Rigid)

ยึดติดกับแผนเดิม ขั้นตอนเยอะ กลัวความล้มเหลว รอคำสั่งจากเบื้องบน

ทีมที่ยืดหยุ่น (Agile)

พร้อมปรับแผนเสมอ ทดลองสิ่งใหม่ ล้มให้ไว ลุกให้เร็ว เรียนรู้จากข้อผิดพลาด

` }, { id: "ch4_2", tag: "บทที่ 4 : ทีมเวิร์คที่ยืดหยุ่น", title: "แนวคิดการทำงานแบบ Agile", render: () => `
แนวคิดการทำงานแบบ Agile

หัวใจของ Agile Team

Break it down (ซอยเป้าหมาย)

หั่นงานใหญ่โปรเจกต์ยาวเป็นเดือน ให้กลายเป็นก้าวเล็กๆ (Sprint) รายสัปดาห์ เพื่อให้เห็นผลลัพธ์ไว

Iterate & Improve (ทำซ้ำและพัฒนา)

ปล่อยเวอร์ชั่นแรกออกไปก่อน (MVP) ไม่ต้องรอให้สมบูรณ์ 100% แล้วนำ Feedback มาปรับปรุง

Cross-functional (ผสานทักษะ)

สลายไซโล (Silo) ดึงคนที่มีทักษะหลากหลายมาทำงานร่วมกันอย่างใกล้ชิด

` }, { id: "ch4_3", tag: "บทที่ 4 : ทีมเวิร์คที่ยืดหยุ่น", title: "Interactive: จับคู่วิธีรับมือ", render: () => `
Interactive: จับคู่วิธีรับมือ
Interactive

รับมือกับความเปลี่ยนแปลง

"ลูกค้าโทรมาแจ้งว่าขอเปลี่ยนโจทย์สำคัญกะทันหัน ซึ่งอาจกระทบงานที่ทีมทำไปแล้วกว่า 70%!"
` }, { id: "ch4_4", tag: "บทที่ 4 : ทีมเวิร์คที่ยืดหยุ่น", title: "ทีมที่ปรับตัวคือทีมที่อยู่รอด", render: () => `
ทีมที่ปรับตัวคือทีมที่อยู่รอด
Actionable Takeaway

สร้าง Resilience ให้ทีม

Resilience หรือ ความสามารถในการเด้งกลับจากความล้มเหลว คือคุณสมบัติของทีมระดับท็อป

Take Action ทันที:

  • Fail Fast, Learn Faster: เปลี่ยนความล้มเหลวให้เป็นบทเรียน อย่าลงโทษคนที่ทำพลาดตอนพยายามทดลองสิ่งใหม่
  • Retrospective (ถอดบทเรียน): หลังจบโปรเจกต์ นั่งคุยกันว่า "อะไรเวิร์ค" "อะไรไม่เวิร์ค" และ "เราจะทำให้ดีขึ้นได้อย่างไร"
  • Stay Flexible: มองแผนงานเป็น "เข็มทิศ" ชี้ทาง มากกว่าเป็น "รางรถไฟ" ที่ห้ามออกนอกเส้นทาง
` }, { id: "ch5_1", tag: "บทที่ 5 : ก้าวสู่ชัยชนะไปด้วยกัน", title: "ทำไมการฉลองถึงสำคัญ?", render: () => `
ทำไมการฉลองถึงสำคัญ?

ทำไมการฉลองถึงสำคัญ?

คนเราไม่ใช่เครื่องจักร การวิ่งตามเป้าหมายโดยไม่หยุดพักชื่นชมผลงาน จะทำให้เกิดภาวะ Burnout ได้ง่าย

เติมพลังใจ (Recharge)

สมองจะหลั่งสารโดปามีน (Dopamine) เมื่อได้รับการยอมรับ ทำให้มีแรงจูงใจทำสิ่งดีๆ ต่อไป

ฉลอง Small Wins

ไม่ต้องรอให้จบโปรเจกต์ใหญ่ แค่งานย่อยเสร็จ หรือแก้บักยากๆ ได้ ก็ควรค่าแก่การ High-five แล้ว

` }, { id: "ch5_2", tag: "บทที่ 5 : ก้าวสู่ชัยชนะไปด้วยกัน", title: "วัฒนธรรมแห่งการชื่นชม", render: () => `
วัฒนธรรมแห่งการชื่นชม

Recognition Culture

เปลี่ยนการชื่นชมให้เป็นนิสัยประจำทีม (Culture of Appreciation)

ชื่นชมอย่างเจาะจง (Specific)

แทนที่จะพูดแค่ "เก่งมาก" ลองเปลี่ยนเป็น "สไลด์ที่คุณทำเมื่อวานข้อมูลแน่นมาก ทำให้เราปิดการขายได้ง่ายเลย"

ถูกที่ ถูกเวลา (Timely)

ชื่นชมให้เร็วที่สุดหลังจากเหตุการณ์นั้นผ่านไป อย่าเก็บไว้รอประเมินปลายปี

ชมต่อหน้าสาธารณะ (Public Recognition)

การประกาศความดีความชอบในที่ประชุมทีม หรือ Group Chat ช่วยยกระดับความภาคภูมิใจ และเป็นตัวอย่างที่ดีให้กับคนอื่น

` }, { id: "ch5_3", tag: "บทที่ 5 : ก้าวสู่ชัยชนะไปด้วยกัน", title: "Interactive: วันนี้คุณชื่นชมเพื่อนแล้วหรือยัง?", render: () => `
Interactive: วันนี้คุณชื่นชมเพื่อนแล้วหรือยัง?
Interactive

ภารกิจสร้างรอยยิ้มวันนี้!

คุณจะเลือกทำสิ่งไหนให้กับเพื่อนร่วมทีมภายในวันนี้? (เลือกได้มากกว่า 1 ข้อ)

` }, { id: "ch5_4", tag: "บทที่ 5 : ก้าวสู่ชัยชนะไปด้วยกัน", title: "ทีมที่ชนะไปด้วยกัน (Final Wrap-up)", render: () => `
ทีมที่ชนะไปด้วยกัน (Final Wrap-up)
Conclusion

บทสรุป: ทีมที่ชนะไปด้วยกัน

การสร้าง Team Synergy ไม่ใช่เวทมนตร์ แต่คือศิลปะแห่งการประกอบร่างคนธรรมดา ให้กลายเป็นฟันเฟืองที่ทรงพลัง

5 รหัสลับ ทีมเวิร์คทรงพลัง

1. Shared Goal: เป้าหมายเดียว มุ่งมั่นไปด้วยกัน
2. Seamless Comm: สื่อสารตรงไปตรงมา ฟังด้วยใจ
3. Trust: เชื่อใจ พึ่งพาได้ ลดความเห็นแก่ตัว
4. Adaptability: ปรับตัวไว ล้มแล้วลุกให้เร็ว
5. Celebration: ฉลองทุกก้าวเล็กๆ ส่งต่อพลังบวก

ขอให้คุณมีความสุขกับการสร้างยอดทีมของคุณนะครับ!

` } ]; let currentIndex = 0; const polcaDetails = { P: "🗺️ P - Planning (การวางแผน): กำหนดเป้าหมายที่ชัดเจนและวัดผลได้ เพื่อให้ทีมรู้ทิศทางตรงกัน ป้องกันปัญหา 'ทำงานเหนื่อยแทบตาย แต่นายบอกผิดเป้า'", O: "🗂️ O - Organising (การจัดระบบงานและเวลา): จัดสรรงานให้ถูกคน (Right man on the right job) แบ่งหน้าที่ชัดเจน และจัดตารางไม่ให้จมอยู่กับการประชุมไร้สาระ", L: "🧭 L - Leading (การนำทางและสร้างแรงบันดาลใจ): ทำให้ลูกน้อง 'อยากทำ' ไม่ใช่แค่ทำเพราะโดนสั่ง สื่อสารวิสัยทัศน์ และอยู่เคียงข้างเวลาทีมเจอปัญหา", C: "🔍 C - Controlling (การควบคุมและติดตามผล): วางจุดตรวจเช็ก (Checkpoints) เพื่อฟีดแบ็ก แก้ไขข้อผิดพลาดตั้งแต่เนิ่นๆ โดยไม่ใช่การนั่งจับผิด", A: "🏆 A - Achieving (การขับเคลื่อนจนได้ผลสำเร็จ): รวมพลัง P, O, L, C เพื่อเปลี่ยนแผนงานให้กลายเป็นผลงานที่ส่งมอบได้จริงตรงตามกำหนดเวลา" }; function selectPolca(key) { playTone(520, 'sine', 0.08); ['P', 'O', 'L', 'C', 'A'].forEach(k => { const el = document.getElementById('polca-tab-' + k); if (el) { if (k === key) { el.className = 'p-2.5 rounded-xl bg-slate-800 border-2 border-emerald-400 transition-all hover:bg-slate-700'; } else { el.className = 'p-2.5 rounded-xl bg-slate-900 border border-slate-700 transition-all hover:bg-slate-700'; } } }); document.getElementById('polcaDetailText').innerHTML = polcaDetails[key]; } // ─── INTERACTIVE ACTIVITIES LOGIC ────────────────────────────────────────── function checkABCTask(type) { const fb = document.getElementById('abcFeedback'); if (!fb) return; if (type === 'A') { playSuccessSound(); fb.className = 'text-xs px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-400 font-bold border border-emerald-500/40'; fb.innerHTML = 'ถูกต้อง! ✅ ปัญหาระบบล่มกระทบธุรกิจวงกว้าง ต้องจัดการทันที (Task A)'; triggerConfetti(); } else { playTone(300, 'sawtooth', 0.15); fb.className = 'text-xs px-2 py-0.5 rounded bg-rose-500/20 text-rose-400 font-bold border border-rose-500/40'; fb.innerHTML = 'ยังไม่ตรงครับ ⚠️ งานนี้ส่งผลต่อธุรกิจทันที ไม่ควรรอหรือส่งต่อ ต้องแก้ด่วน!'; } } function selectFeedbackChoice(choice) { const res = document.getElementById('feedbackResult'); [1, 2, 3].forEach(c => { const el = document.getElementById('fb-choice-' + c); if (el) el.className = 'w-full text-left p-2.5 rounded-xl bg-slate-900 border border-slate-700 hover:bg-slate-800 transition-all'; }); const selectedEl = document.getElementById('fb-choice-' + choice); if (choice === 2) { playSuccessSound(); if (selectedEl) selectedEl.className = 'w-full text-left p-2.5 rounded-xl bg-emerald-950/60 border-2 border-emerald-400 transition-all shadow-md'; res.innerHTML = '✨ ยอดเยี่ยมมาก! ตรงตามสูตร SBI ครบถ้วน: ระบุสถานการณ์ (S) + พฤติกรรมที่เห็น (B) + ผลกระทบต่องาน (I) และเปิดโอกาสให้ร่วมแก้ปัญหา ได้ทั้งงานและได้ใจลูกทีมครับ'; triggerConfetti(); } else if (choice === 1) { playTone(320, 'triangle', 0.15); if (selectedEl) selectedEl.className = 'w-full text-left p-2.5 rounded-xl bg-rose-950/60 border-2 border-rose-400 transition-all'; res.innerHTML = '⚠️ ติดกับดักการด่ากราด: การพูดว่า "ไม่มีความรับผิดชอบ" เป็นการโจมตีนิสัยส่วนตัว ทำให้ลูกน้องต่อต้านทันทีครับ'; } else { playTone(320, 'triangle', 0.15); if (selectedEl) selectedEl.className = 'w-full text-left p-2.5 rounded-xl bg-amber-950/60 border-2 border-amber-400 transition-all'; res.innerHTML = '⚠️ ติดกับดัก Solo Hero: การเอามาทำเองตัดปัญหา ไม่ช่วยให้ลูกน้องพัฒนา และคุณจะทำงานหนักจน Burnout ครับ'; } } let selectedHabits = new Set(); function toggleHabitCommit(id) { playTone(550 + id * 50, 'sine', 0.1); const card = document.getElementById('habit-card-' + id); if (selectedHabits.has(id)) { selectedHabits.delete(id); if (card) { card.classList.remove('bg-amber-950/40', 'border-amber-400'); card.classList.add('bg-slate-900', 'border-slate-700'); const icon = card.querySelector('.habit-icon'); if (icon) icon.className = 'w-5 h-5 text-slate-600 habit-icon'; } } else { selectedHabits.add(id); if (card) { card.classList.remove('bg-slate-900', 'border-slate-700'); card.classList.add('bg-amber-950/40', 'border-amber-400'); const icon = card.querySelector('.habit-icon'); if (icon) icon.className = 'w-5 h-5 text-amber-400 habit-icon'; } } const summary = document.getElementById('habitSummaryText'); if (selectedHabits.size > 0) { summary.innerHTML = `🎉 คุณเลือกคอมมิท ${selectedHabits.size} กิจวัตร! 'ความสำเร็จเล็กๆ ที่ทำซ้ำทุกวัน คือพลังขับเคลื่อนที่ยิ่งใหญ่ที่สุดของผู้นำ'`; triggerConfetti(); } else { summary.innerHTML = '✨ คลิกเลือกนิสัยประจำวันของคุณ แล้วระบบจะบันทึกเป้าหมายพร้อมแสดงพลังความมุ่งมั่น!'; } lucide.createIcons(); } function triggerConfetti() { if (typeof confetti === 'function') { confetti({ particleCount: 50, spread: 60, origin: { y: 0.7 } }); } } function selectDilemma(type) { playTone(type === 'firm' ? 620 : 450, 'sine', 0.1); const elG = document.getElementById('dilemma-gentle'); const elF = document.getElementById('dilemma-firm'); const det = document.getElementById('dilemmaDetail'); if (type === 'firm') { if (elF) elF.className = 'p-3 rounded-xl bg-emerald-950/60 border-2 border-emerald-400 text-left transition-all shadow-md'; if (elG) elG.className = 'p-3 rounded-xl bg-slate-900 border border-slate-700 text-left transition-all opacity-60'; if (det) det.innerHTML = '🎯 หัวใจของ นุ่มนวลแต่หนักแน่น: รักษาน้ำใจลูกทีม ใช้คำพูดสุภาพ แต่ยึดมั่นใน KPI และเป้าหมายของทีมอย่างไม่ประนีประนอม'; triggerConfetti(); } else { if (elG) elG.className = 'p-3 rounded-xl bg-amber-950/60 border-2 border-amber-400 text-left transition-all shadow-md'; if (elF) elF.className = 'p-3 rounded-xl bg-slate-900 border border-slate-700 text-left transition-all opacity-60'; if (det) det.innerHTML = '⚠️ หลุมพราง เกรงใจจนเสียงาน: ไม่กล้าเตือนเพราะกลัวเขาเสียใจ สุดท้ายงานพังทั้งแผนก และลูกน้องก็ไม่ได้เรียนรู้'; } } function calculateScore() { const checks = document.querySelectorAll('.quiz-check:checked').length; playTone(600 + checks * 100, 'sine', 0.1); const res = document.getElementById('quizResult'); if (checks === 0) { res.innerHTML = `✨ กัปตันตัวจริง! คุณมี Mindset ของผู้นำยุคใหม่ ไว้ใจทีมและเปิดโอกาสให้คนรอบข้างได้เติบโตครับ`; } else if (checks <= 2) { res.innerHTML = `⚠️ เริ่มมีอาการติดกับดัก Solo Hero! คุณยังกั๊กงานไว้ทำเองบางส่วน ลองปล่อยมือทีละนิด แล้วผันตัวมาเป็นโค้ชครับ`; } else { res.innerHTML = `🚨 ภาวะฮีโร่สายเดี่ยวขั้นวิกฤต! คุณกำลังทำงานแทนทุกคนในทีม รีบกระจายงานด่วนก่อนที่จะ Burnout ทั้งทีมและตัวคุณเองครับ`; } } function celebrateFinish() { playSuccessSound(); if (typeof confetti === 'function') { confetti({ particleCount: 120, spread: 80, origin: { y: 0.6 } }); } } // ─── Image Lightbox for High-Res Sketchnote Zoom ─────────────────────────── function openImageLightbox(src) { playTone(480, 'sine', 0.08); const modal = document.getElementById('imageLightboxModal'); const img = document.getElementById('lightboxImg'); if (modal && img) { img.src = src; modal.classList.remove('hidden'); lucide.createIcons(); } } function closeImageLightbox() { playTone(400, 'triangle', 0.08); const modal = document.getElementById('imageLightboxModal'); if (modal) modal.classList.add('hidden'); } // Initialize All Slides into the Carousel Track Side-by-Side (Mobile Friendly Scroll) function initSliderTrack() { const track = document.getElementById('sliderTrack'); track.innerHTML = cards.map((card, idx) => `
${card.render()}
`).join(''); lucide.createIcons(); updateSliderPosition(); triggerTextFadeIn(0, true); // initial load: short 0.4s delay } // Pure Physical Horizontal Slide Transition (Smooth & Visible, Zero Dimming!) function updateSliderPosition() { const track = document.getElementById('sliderTrack'); track.style.transform = `translate3d(-${currentIndex * 100}%, 0, 0)`; // Update counters & progress document.getElementById('currentCardNum').innerText = currentIndex + 1; document.getElementById('totalCardsNum').innerText = cards.length; const mobileCur = document.getElementById('mobileCurrentNum'); if (mobileCur) mobileCur.innerText = currentIndex + 1; const mobileTot = document.getElementById('mobileTotalNum'); if (mobileTot) mobileTot.innerText = cards.length; const progressPercent = ((currentIndex + 1) / cards.length) * 100; document.getElementById('progressBar').style.width = progressPercent + '%'; const headerTag = document.getElementById('headerChapterTag'); if (headerTag) { headerTag.innerText = currentIndex === 0 ? '• หน้าปก MiniBook' : `• ${cards[currentIndex].tag}`; } // Update Floating Side Buttons const sidePrevBtn = document.getElementById('sidePrevBtn'); const mobilePrevBtn = document.getElementById('mobilePrevBtn'); if (sidePrevBtn) sidePrevBtn.disabled = (currentIndex === 0); if (mobilePrevBtn) mobilePrevBtn.disabled = (currentIndex === 0); const sideNextBtn = document.getElementById('sideNextBtn'); if (sideNextBtn) { if (currentIndex === cards.length - 1) { sideNextBtn.innerHTML = ``; } else { sideNextBtn.innerHTML = ``; } } // Update next button label on mobile const nextBtnLabel = document.getElementById('nextBtnLabel'); const nextBtnIcon = document.getElementById('nextBtnIcon'); if (nextBtnLabel && nextBtnIcon) { if (currentIndex === cards.length - 1) { nextBtnLabel.innerText = 'จบเนื้อหา'; nextBtnIcon.setAttribute('data-lucide', 'check'); } else { nextBtnLabel.innerText = 'ถัดไป'; nextBtnIcon.setAttribute('data-lucide', 'chevron-right'); } } // Reset scroll position to top on slide change (Mobile friendliness) const currentSlideEl = document.getElementById(`slide-item-${currentIndex}`); if (currentSlideEl) { currentSlideEl.scrollTop = 0; } renderDots(); lucide.createIcons(); // Trigger text panel fade-in animation for this slide triggerTextFadeIn(currentIndex); // Play narration if enabled + schedule auto-slide for this page if (narrationEnabled && hasUserInteracted) { playCurrentPageNarration(); scheduleAutoSlide(); // wait for audio → then 3s after it ends } else if (!narrationEnabled && hasUserInteracted) { scheduleAutoSlide(); // no audio → start 60s countdown directly } } function renderDots() { const dotsContainer = document.getElementById('dotsContainer'); dotsContainer.innerHTML = cards.map((_, i) => ` `).join(''); } // ─── Text Panel: Fade-in from bottom ───────────────────────────────────────── // Safe because we go opacity:0→1 (invisible→visible), no snap issue. // CSS delay (backwards fill) keeps text hidden while track is still sliding. function triggerTextFadeIn(slideIndex, isInitial = false) { const slide = document.getElementById(`slide-item-${slideIndex}`); if (!slide) return; const grid = slide.querySelector('[class*="grid"]'); if (!grid || grid.children.length < 2) return; const textCol = grid.children[1]; // Remove both classes (in case re-navigating to same slide) textCol.classList.remove('text-enter-nav', 'text-enter-init'); // Double rAF ensures class removal is painted before re-adding requestAnimationFrame(() => requestAnimationFrame(() => { textCol.classList.add(isInitial ? 'text-enter-init' : 'text-enter-nav'); })); } // ─── End Text Fade ─────────────────────────────────────────────────────────── function nextCard() { hasUserInteracted = true; resetAutoSlideTimer(); if (currentIndex < cards.length - 1) { playNextSound(); currentIndex++; updateSliderPosition(); } else { celebrateFinish(); } } function prevCard() { hasUserInteracted = true; resetAutoSlideTimer(); if (currentIndex > 0) { playPrevSound(); currentIndex--; updateSliderPosition(); } } function goToCard(i) { hasUserInteracted = true; resetAutoSlideTimer(); if (i !== currentIndex) { playTone(500); currentIndex = i; updateSliderPosition(); } } // Modal Table of Contents // Modal Table of Contents with Proper Chapter Grouping & Indentation function openIndexModal() { playTone(450); const modal = document.getElementById('indexModal'); const list = document.getElementById('indexList'); let currentGroup = ''; let html = ''; cards.forEach((card, i) => { if (card.tag !== currentGroup) { currentGroup = card.tag; if (currentGroup.includes('หน้าปก')) { html += `
${currentGroup}
`; } else { html += `
${currentGroup}
`; } } const isCover = (i === 0); const indentClass = isCover ? 'ml-0' : 'ml-3 pl-2.5 border-l-2 border-slate-700/60'; html += `
${i + 1}
${card.title}
`; }); list.innerHTML = html; modal.classList.remove('hidden'); lucide.createIcons(); } function closeIndexModal() { playTone(400); document.getElementById('indexModal').classList.add('hidden'); } // Keyboard navigation (Left / Right / Space / A / D / Escape) document.addEventListener('keydown', (e) => { hasUserInteracted = true; if (e.key === 'ArrowRight' || e.key === ' ' || e.key === 'd' || e.key === 'D') { e.preventDefault(); nextCard(); } else if (e.key === 'ArrowLeft' || e.key === 'a' || e.key === 'A') { e.preventDefault(); prevCard(); } else if (e.key === 'Escape') { closeIndexModal(); } }); // Touch swipe support for mobile (with vertical scroll protection) let touchStartX = 0; let touchStartY = 0; document.addEventListener('touchstart', e => { hasUserInteracted = true; touchStartX = e.changedTouches[0].screenX; touchStartY = e.changedTouches[0].screenY; }, { passive: true }); document.addEventListener('touchend', e => { const deltaX = touchStartX - e.changedTouches[0].screenX; const deltaY = touchStartY - e.changedTouches[0].screenY; // Trigger horizontal slide only if gesture is predominantly horizontal if (Math.abs(deltaX) > 45 && Math.abs(deltaX) > Math.abs(deltaY) * 1.4) { if (deltaX > 0) nextCard(); else prevCard(); } }, { passive: true }); // ─── Fullscreen & Landscape Orientation Control ───────────────────────── function isAppFullscreen() { return !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement); } function requestAppFullscreen() { const docEl = document.documentElement; const rfs = docEl.requestFullscreen || docEl.webkitRequestFullscreen || docEl.mozRequestFullScreen || docEl.msRequestFullscreen; if (rfs) { rfs.call(docEl).catch(err => { console.log('Fullscreen request ignored or failed:', err); }); } hideLandscapePrompt(); } function exitAppFullscreen() { const efs = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen; if (efs && isAppFullscreen()) { efs.call(document).catch(err => console.log('Exit fullscreen failed:', err)); } } function toggleFullscreen() { playTone(500, 'sine', 0.08); if (isAppFullscreen()) { exitAppFullscreen(); } else { requestAppFullscreen(); } } function updateFullscreenUI() { const iconSlot = document.getElementById('fullscreenIconSlot'); if (!iconSlot) return; if (isAppFullscreen()) { iconSlot.innerHTML = ``; } else { iconSlot.innerHTML = ``; } lucide.createIcons(); } document.addEventListener('fullscreenchange', updateFullscreenUI); document.addEventListener('webkitfullscreenchange', updateFullscreenUI); function showLandscapePrompt() { const pill = document.getElementById('landscapePromptPill'); if (pill && !isAppFullscreen()) { pill.classList.remove('hidden'); pill.classList.add('flex'); lucide.createIcons(); // Auto-hide prompt after 6 seconds if not clicked setTimeout(() => { hideLandscapePrompt(); }, 6000); } } function hideLandscapePrompt() { const pill = document.getElementById('landscapePromptPill'); if (pill) { pill.classList.add('hidden'); pill.classList.remove('flex'); } } function handleOrientationChange() { const isLandscape = window.matchMedia('(orientation: landscape)').matches || (window.innerWidth > window.innerHeight && window.innerHeight < 600); if (isLandscape && !isAppFullscreen() && window.innerHeight < 650) { // Device tilted to landscape! Attempt auto fullscreen on gesture or prompt showLandscapePrompt(); } else { hideLandscapePrompt(); } // Re-trigger layout alignment if (typeof updateSliderPosition === 'function') { updateSliderPosition(); } } window.addEventListener('resize', handleOrientationChange); window.addEventListener('orientationchange', () => { setTimeout(handleOrientationChange, 250); }); // Auto-play on first click anywhere on screen + check fullscreen on user gesture if tilted document.addEventListener('click', () => { if (!hasUserInteracted) { hasUserInteracted = true; if (narrationEnabled && !isPlaying) { playCurrentPageNarration(); } } // If user taps screen while landscape and not fullscreen, prompt can be triggered or entered const isLandscape = window.matchMedia('(orientation: landscape)').matches && window.innerHeight < 600; if (isLandscape && !isAppFullscreen()) { const pill = document.getElementById('landscapePromptPill'); if (pill && pill.classList.contains('hidden')) { showLandscapePrompt(); } } }, { once: false }); // Initial render // Fallback: Start audio on the very first gesture (click, tap, key) if browser blocked autoplay ['click', 'touchstart', 'pointerdown', 'keydown'].forEach(evt => { window.addEventListener(evt, () => { hasUserInteracted = true; if (narrationEnabled && !isPlaying) { playCurrentPageNarration(); } }, { once: true }); }); window.addEventListener('DOMContentLoaded', () => { initSliderTrack(); updateMasterNarrationUI(); updateFullscreenUI(); handleOrientationChange(); if (narrationEnabled) { playCurrentPageNarration(); } }); // --- Interactive Global Functions --- window.updateCh1Score = function() { const checkboxes = document.querySelectorAll('#ch1_checklist input[type="checkbox"]'); let checkedCount = 0; checkboxes.forEach(cb => { if(cb.checked) checkedCount++; }); const feedbackObj = document.getElementById('ch1_feedback'); if(!feedbackObj) return; const titleObj = document.getElementById('ch1_result_title'); const descObj = document.getElementById('ch1_result_desc'); feedbackObj.classList.remove('hidden'); if (checkedCount === 4) { titleObj.innerText = "สุดยอดทีมเวิร์ค! (4/4)"; descObj.innerText = "ทีมของคุณมีความเป็นน้ำหนึ่งใจเดียวกันสูงมาก รักษามาตรฐานนี้ไว้นะครับ!"; window.playSuccessSound && window.playSuccessSound(); } else if (checkedCount >= 2) { titleObj.innerText = "มาถูกทางแล้วครับ (2-3/4)"; descObj.innerText = "ทีมของคุณมีพื้นฐานที่ดี ลองเสริมจุดที่ยังขาดดู แล้วจะทรงพลังขึ้นไปอีกขั้น!"; window.playSuccessSound && window.playSuccessSound(); } else { titleObj.innerText = "จุดเริ่มต้นที่ดี (0-1/4)"; descObj.innerText = "แค่รู้ว่าเราอยู่จุดไหนก็ถือเป็นการเริ่มต้นที่ดีครับ บทเรียนถัดไปจะช่วยคุณได้อย่างแน่นอน!"; } }; window.checkCh2 = function(ans) { const fb = document.getElementById('ch2_feedback'); if(!fb) return; const t = document.getElementById('ch2_res_title'); const d = document.getElementById('ch2_res_desc'); fb.classList.remove('hidden', 'border-rose-500', 'border-emerald-500', 'border-amber-500'); if(ans === 'A') { fb.classList.add('border-amber-500'); t.className = 'font-bold text-amber-400'; t.innerText = "เกิดปัญหา Artificial Harmony"; d.innerText = "การเลี่ยงความขัดแย้ง ทำให้ทีมพลาดโอกาสป้องกันความเสียหาย และไม่เกิดการพัฒนาครับ"; } else if (ans === 'B') { fb.classList.add('border-rose-500'); t.className = 'font-bold text-rose-400'; t.innerText = "ระวังเกิด Personal Attack"; d.innerText = "การใช้คำพูดตัดสินรุนแรง อาจทำให้เพื่อนร่วมทีมตั้งกำแพง และทำลายความสัมพันธ์ในทีมได้"; } else { fb.classList.add('border-emerald-500'); t.className = 'font-bold text-emerald-400'; t.innerText = "ยอดเยี่ยมมากครับ!"; d.innerText = "คุณแยก 'ไอเดีย' ออกจาก 'ตัวบุคคล' และชวนให้เกิดความร่วมมือ (Collaboration) อย่างสร้างสรรค์"; window.playSuccessSound && window.playSuccessSound(); } }; window.checkCh3 = function(ans) { const fb = document.getElementById('ch3_feedback'); if(!fb) return; const t = document.getElementById('ch3_res_title'); const d = document.getElementById('ch3_res_desc'); fb.className = 'mt-4 p-4 rounded-xl border-l-4 bg-slate-800'; if(ans === 'C') { fb.classList.add('border-emerald-500'); t.className = 'font-bold text-emerald-400'; t.innerText = "High Trust Culture!"; d.className = 'text-sm text-slate-300 mt-1'; d.innerText = "ทีมของคุณมีความปลอดภัยทางใจสูง (Psychological Safety) กล้ายอมรับจุดอ่อน ซึ่งเป็นรากฐานของทีมที่ทรงพลังครับ"; window.playSuccessSound && window.playSuccessSound(); } else { fb.classList.add('border-amber-500'); t.className = 'font-bold text-amber-400'; t.innerText = "สัญญาณอันตราย (Low Trust)"; d.className = 'text-sm text-slate-300 mt-1'; d.innerText = "การปัดความรับผิดชอบหรือความเงียบ แสดงว่าทีมยังมี 'ความกลัว' แฝงอยู่ ต้องรีบสร้าง Psychological Safety ครับ"; } }; window.checkCh4 = function(ans) { const fb = document.getElementById('ch4_feedback'); if(!fb) return; const t = document.getElementById('ch4_res_title'); const d = document.getElementById('ch4_res_desc'); fb.className = 'mt-4 p-4 rounded-xl border-l-4 bg-slate-800'; if(ans === 'C') { fb.classList.add('border-emerald-500'); t.className = 'font-bold text-emerald-400'; t.innerText = "วิถีแห่ง Agile ครับ!"; d.className = 'text-sm text-slate-300 mt-1'; d.innerText = "การกอดรับความเปลี่ยนแปลง (Embrace Change) และร่วมมือกับลูกค้า (Customer Collaboration) คือหัวใจสำคัญของการอยู่รอด!"; window.playSuccessSound && window.playSuccessSound(); } else { fb.classList.add('border-amber-500'); t.className = 'font-bold text-amber-400'; t.innerText = "ระวังจะตึงเกินไป หรือพังเพราะความเครียด"; d.className = 'text-sm text-slate-300 mt-1'; d.innerText = "การยึดติดแผนเดิม หรือตื่นตระหนก จะทำให้สถานการณ์แย่ลง ลองดึงสติแล้วจัดลำดับความสำคัญใหม่ (Reprioritize) นะครับ"; } }; window.updateCh5Score = function() { const cb = document.querySelectorAll('#ch5_checklist input'); let c = 0; cb.forEach(x => x.checked && c++); const fb = document.getElementById('ch5_feedback'); if(!fb) return; if (c > 0) { fb.classList.remove('hidden'); window.playSuccessSound && window.playSuccessSound(); } else { fb.classList.add('hidden'); } };